<?php
/**
* エラーチェッククラス
**/
require_once( '../system/Class_M_DAO.php' );
class Class_M_USER extends Class_M_DAO {
	//protected properties begin
	/**
	 *
	 * テーブル名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_table = "M_USER";
	
	/**
	 *
	 * 主キー名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_pkey = "id";
	
	/**
	 *
	 * ソート順
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	 protected $_order = "id";
	 
	 protected $_cols  = array(
	 	"state"           => array(AOKI_VARTYPE_STR),
		"id"              => array(AOKI_VARTYPE_STR),
		"user_name1"      => array(AOKI_VARTYPE_STR),
	    "user_name2"      => array(AOKI_VARTYPE_STR),
		"workshop_name"   => array(AOKI_VARTYPE_STR),
	    "local_name"      => array(AOKI_VARTYPE_STR),
	    "zipcode"         => array(AOKI_VARTYPE_STR),
	    "email"           => array(AOKI_VARTYPE_STR),
	    "street_name"     => array(AOKI_VARTYPE_STR),
	    "address"         => array(AOKI_VARTYPE_STR),
	    "tel_number"      => array(AOKI_VARTYPE_STR),
	    "mobile_number"   => array(AOKI_VARTYPE_STR),
	    "send"            => array(AOKI_VARTYPE_STR),
	    "sex"             => array(AOKI_VARTYPE_STR),
	    "birthday"        => array(AOKI_VARTYPE_STR),
	    "workshop_name_furikana"        => array(AOKI_VARTYPE_STR),
	    "user_name_furikana2"        => array(AOKI_VARTYPE_STR),
	    "user_name_furikana1"        => array(AOKI_VARTYPE_STR),
	    "login_pwd"        => array(AOKI_VARTYPE_STR),
	    "llogin_id"        => array(AOKI_VARTYPE_STR),
	 );
	
	 protected $_checks  = array(
		"login_id"   => array( "EXIST" ,"ALNUM" ),
		"login_pwd"  => array( "EXIST" ,"ALNUM" ),
		"user_name"  => array( "EXIST" ),
		"auth"       => array( "EXIST" ,"NUM" ),
		"email"      => array( "EXIST" ,"EMAIL" ),
		"login_ng"   => array("NUM" ),
		
	 );
	 
	 //maxlength 
	 protected $_maxlens  = array(
		"login_id"   =>  20 ,
		"user_name"  =>  20 ,
		"auth"       =>  1 ,
		"email"      =>  100 ,
		"login_pwd"  =>  200,
		"login_ng"   =>  1
	 );
	
	 public function search($where='' ,&$page = NULL ){	
		$sql = "SELECT * , b.local_name
                FROM m_user a LEFT JOIN M_LOCAL b ON a.local_name = b.local_cd";
		$sqlcnt = "SELECT COUNT(*) AS cnt FROM m_user a ";
		return  parent::search($where ,$page ,$sql,$sqlcnt);
	}
	 
	 public function get_rows(){
	 	$sql = "SELECT  * FROM {$this->_table}";
	 	return parent::get_rows($sql);
	 }
	 
	 public function search_csv($where){	
	    $sql = "SELECT * , b.local_name
                FROM m_user a LEFT JOIN M_LOCAL b ON a.local_name = b.local_cd";
		$page = null;
		return  parent::search($where ,$page ,$sql);
	}
	
}

?>